<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['diy']=$this->plugin_setting('diy');
$basic=$this->plugin_setting('basic');
$return['hdps']=$basic['hdps'];
if($_RQ['op']=='main'){
	$mystoreid=pdo_getcolumn('jy_kexie_user',array('mid'=>$_SESSION['uid']),'storeid');
	if($mystoreid){
		$return['store']=pdo_get('jy_kexie_store',array('id'=>$mystoreid));
	}
	$return['province']=file_get_contents('core/resource/area.txt');
	$return['province']=unserialize($return['province']);
	$return['pcd']=array(
		'province' =>trim($_RQ['province']),
		'city' =>trim($_RQ['city']),
		'district' =>trim($_RQ['district']),
	);
	set_html('title','老师列表');
	$return['sharedata']=array(
		'title'=>'老师列表'.$basic['share_title'],
		'desc'=>'老师列表'.$basic['share_desc'],
		'link'=>custom_url('jy_kexie/worker_list/',true),
		'imgUrl'=>ATTACHMENT_URL.$basic['share_image'],
	);
	exi($return);
}
if($_RQ['op']=='getlist'){
	$post=get_postdata();
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	$type=intval($_RQ['type']);
	if(!empty($_RQ['keyword'])){
		$params['name like']='%'.trim($_RQ['keyword']).'%';
		$return['params']['keyword']=$_RQ['keyword'];
	}
	if($_RQ['storeid']){
		$params['storeid']=intval($_RQ['storeid']);
	}
	//排序老师
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['status']=0;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'fields'=>$fields,
		'orderby'=>$orderby,
	);
	$list=pdo_getslice('jy_kexie_worker',$params,array($pindex,$psize),$total,$fields,'','id desc');
	$sum=0;
	if($list){
		$sum=count($list);
		foreach($list as &$item){		
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			$item['lessontitle']=pdo_getcolumn('jy_kexie_lesson_group',array('id'=>$item['lesson_groupid']),'title');
			$item['storetitle']=pdo_getcolumn('jy_kexie_store',array('id'=>$item['storeid']),'title');
		}
	}
	$return['list']=$list;
	$return['sum']=$sum;
	set_html('title','老师列表');
	$return['sharedata']=array(
		'title'=>'老师列表'.$basic['share_title'],
		'desc'=>'老师列表'.$basic['share_desc'],
		'link'=>custom_url('jy_kexie/worker_list/',true),
		'imgUrl'=>ATTACHMENT_URL.$basic['share_image'],
	);
	exi($return);
}
if($_RQ['op']=='detail'){
	$id=intval($_RQ['id']);
	if(!$id){
		$all=pdo_getall('jy_kexie_worker',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'','','id desc');
		$id=$all[0]['id'];
	}
	$return['item']=pdo_get('jy_kexie_worker',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	$return['item']['lesson_group']=$this->get('lesson_group',array('id'=>$return['item']['lesson_groupid']));
	if($return['item']['storeid']){
		$return['item']['store']=$this->get('store',array('id'=>$return['item']['storeid']));
		$return['item']['store']['pcd']=json_decode($return['item']['store']['pcd'],true);
	}
	$return['item']['statustitle']=$this->order_status[$return['item']['status']];
	$return['item']['createtime']=date('Y-m-d H:i:s',$return['item']['createtime']);
	set_html('title','老师详情');
	exi($return);
}
	
